package com.china.zhuoyue.ui.activity.business.area

import android.graphics.Paint
import android.view.View
import com.china.zhuoyue.R
import com.china.zhuoyue.api.business.area.BusICircle
import com.china.zhuoyue.databinding.ActivityBusinessAreaDetailBinding
import com.china.zhuoyue.ui.base.BaseActivity
import com.china.zhuoyue.ui.ext.format
import com.china.zhuoyue.ui.helper.InjectBundle
import com.china.zhuoyue.ui.utils.GlideImageLoader
import com.china.zhuoyue.ui.utils.Utils
import com.youth.banner.BannerConfig

class BusinessAreaDetailActivity : BaseActivity<ActivityBusinessAreaDetailBinding>() {
    companion object {
//        const val ACTIVITY_ID = "mActivityId"
//
//        const val DISTANCE = "mDistance"

        const val BUS_ICIRCLE = "mBusICircle"
    }

//    private lateinit var mLoadService: LoadService<*>
//    private val mActivityId: Int by InjectBundle()
//    private val mDistance: Int by InjectBundle

    private val mBusICircle: BusICircle by InjectBundle()

    override fun initView() {
        Utils.invasionStatusBar(this)
//        mLoadService = LoadSirHelper.register(this, listener = { onRefresh() })
//        mLoadService.showLoadingBeforeSuccessCallback()
        bindViewClick(vb.ivBack)
    }

    override fun initData() {
        vb.apply {
            mBusICircle.apply {
                banner.apply {
                    setImageLoader(GlideImageLoader())
                    setIndicatorGravity(BannerConfig.RIGHT)
                    setBannerStyle(BannerConfig.CIRCLE_INDICATOR)
                    setDelayTime(2000)
                    setImages(mainImgs)
                }.start()
                tvTitle.text = title
                tvSecondTitle.text = secondTitle
                tvSold.text = getString(R.string.text_business_area_sold, sold)
                tvPrice.text = getString(R.string.text_rmb, price.format())
                tvMarketPrice.text = getString(R.string.text_rmb, marketPrice.format())
                tvMarketPrice.paint.flags = Paint.STRIKE_THRU_TEXT_FLAG
                tvDistance.text = "${distance}m"
            }
        }
//        onRefresh()
    }

    override fun onClick(v: View?) {
        when (v) {
            vb.ivBack -> onBackPressed()
        }
    }

//    private fun onRefresh() {
//        launchUIBusinessArea({ busicircleActivity(mActivityId) }, ApiObserver(loadService = mLoadService) {
//            it?.apply {
//                vb.apply {
//                    banner.apply {
//                        setImageLoader(GlideImageLoader())
//                        setIndicatorGravity(BannerConfig.RIGHT)
//                        setBannerStyle(BannerConfig.CIRCLE_INDICATOR)
//                        setDelayTime(2000)
//                        setImages(mainImgs)
//                    }.start()
//                    tvTitle.text = title
//                    tvSecondTitle.text = secondTitle
//                    tvSold.text = getString(R.string.text_business_area_sold, sold)
//                    tvPrice.text = getString(R.string.text_rmb, price.format())
//                    tvMarketPrice.text = getString(R.string.text_rmb, marketPrice.format())
//                    tvMarketPrice.paint.flags = Paint.STRIKE_THRU_TEXT_FLAG
//                    tvDistance.text = "${mDistance}m"
//                }
//            }
//        })
//    }
}